from small one page howto to huge articles all in one place
poll results
Last additions:
May 25th. 2007:
April, 26th. 2006:
| 
.  You are here: System->Tips and Tricks
Introducing the -- flagThis tip introduces the -- flag. This flag is supported by many utilities but isn't always documented in the man pages. However, it can be very useful, especially when dealing with malformed filenames. Note: Most programs that make use of --option also support the -- flag since it is a standard feature of GNU getopt(). The -- flag forces everything passed in after it to be an argument to the command. This can be extremely useful when dealing with filenames that start with a - which would normally indicate an option or flag passed to the command. For example, assume that for some reason, there is a file named -file that needs to be deleted. Normally you would use the command rm to delete a file, but this doesn't work since the file in question starts with a -. But by using the -- flag, we force rm to recognize -file as an argument and not an option. Code Listing 1: Using the -- flag // Attempting to use rm results in an error as rm tries to
// process all of the letters as options (f,i,l,e). It fails
// on 'l' since that isn't a valid option for rm.
% ls
-file
% rm -file
rm: invalid option -- l
Try `rm --help' for more information
% rm -- -file
% ls
// -file was successfully removed Note: For more technical information, see man 3 getopt. From http://www.gentoo.org/news/en/gwn/20031013-newsletter.xml
back
|